<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <title>{$goods.goods_name}_{$tpshop_config.shop_info_store_title}</title>
        <meta http-equiv="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
        <meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
        <link rel="stylesheet" type="text/css" href="__STATIC__/css/public.css"/>
        <link rel="stylesheet" type="text/css" href="__STATIC__/css/goods.css?a=121"/>
       
        <script type="text/javascript" src="__STATIC__/js/jquery.js"></script>
        <script type="text/javascript" src="__STATIC__/js/touchslider.dev.js"></script>
        <script src="__PUBLIC__/js/global.js"></script>
        <script src="__PUBLIC__/js/mobile_common.js?a=1111"></script>
        <script src="__STATIC__/js/common.js"></script>
        <script type="text/javascript" src="__STATIC__/js/iscrollv4.2.5.js"></script>
        <script type="text/javascript" src="__STATIC__/js/jquery.lazyload.js"></script>
       

        <script type="text/javascript">

            var myScroll,pullDownEl, pullDownOffset,pullUpEl, pullUpOffset;
            var labeltext1="继续上拉,查看详情";
            var labeltext2="";
            var generatedCount = 0;


            function pullDownAction () {
                var cur_id=parseInt($('.tab_head.on').attr('id').replace('goods_ka',''));

                if(cur_id>1){
                  var pre_id=cur_id-1;
                  $('.tab_head').removeClass('on');
                  $('#goods_ka'+pre_id).addClass('on');
                  $('#user_goods_ka_'+pre_id).css('display','block');
                  var pre_h=$('#user_goods_ka_'+pre_id).height();
                  $('#user_goods_ka_'+pre_id).height(0).animate({'height':pre_h},500);
                  $('#user_goods_ka_'+cur_id).css('display','none');
          
                 }

                 setTimeout(function(){
                    myScroll.refresh(); 
                 },500)
             }

             function pullUpAction () {
               var cur_id=parseInt($('.tab_head.on').attr('id').replace('goods_ka',''));
               var next_id=cur_id+1;
               if(cur_id<4){
                 if(cur_id==2){
                    labeltext1="继续上拉，查看详情"
                 }
                 if(cur_id==3){
                    labeltext1="继续上拉，查看属性"
                 }
                 $('.tab_head').removeClass('on');
                 $('#goods_ka'+next_id).addClass('on');
                 $('#user_goods_ka_'+next_id).css('display','block');
                 /*if(next_id==2){
                    var product_desc='<div>{$goods.goods_content|htmlspecialchars_decode}</div>';
                    //alert($(product_desc).find('img').size())
                        $(product_desc).find('img').each(function(){
                            var src=$(this).attr('src')
                            $('#product_desc').append('<p><img src="'+src+'" class="lazy"></p>');
                        })
             
                    $("img.lazy").lazyload({
                      placeholder : "__STATIC__/images/imgbg.jpg", //用图片提前占位
                        // placeholder,值为某一图片路径.此图片用来占据将要加载的图片的位置,待图片加载时,占位图则会隐藏
                      effect: "fadeIn", // 载入使用何种效果
                        // effect(特效),值有show(直接显示),fadeIn(淡入),slideDown(下拉)等,常用fadeIn
                    });
                 }*/
                // $('#user_goods_ka_'+cur_id).animate({'height':0},500);
                 myScroll.scrollTo(0, -$('#user_goods_ka_'+cur_id).height(), 500);
                 setTimeout(function(){
                  $('#user_goods_ka_'+cur_id).css('display','none');
                   myScroll.scrollTo(0, $('#user_goods_ka_'+cur_id).height(), 0);
                   myScroll.refresh(); 
                 },500)
                 //var htext=$('#thelist').append($('#user_goods_ka_'+next_id).html());
                }
             }


            function loaded() {
                pullDownEl = document.getElementById('pullDown');
                pullDownOffset = pullDownEl.offsetHeight;
                pullUpEl = document.getElementById('pullUp'); 
                pullUpOffset = pullUpEl.offsetHeight;
  
                myScroll = new iScroll('wrapper', {
                    useTransition: true,
                    topOffset: pullDownOffset,
                    onRefresh: function () {
                        if (pullDownEl.className.match('loading')) {
                            pullDownEl.className = '';
                            pullDownEl.querySelector('.pullDownLabel').innerHTML = labeltext2;
                        } else if (pullUpEl.className.match('loading')) {
                            pullUpEl.className = '';
                            pullUpEl.querySelector('.pullUpLabel').innerHTML = labeltext1;
                        }
                    },
                    onScrollMove: function () {
                        if (this.y > 5 && !pullDownEl.className.match('flip')) {
                            pullDownEl.className = 'flip';
                            pullDownEl.querySelector('.pullDownLabel').innerHTML = '释放加载...';
                            this.minScrollY = 0;
                        } else if (this.y < 5 && pullDownEl.className.match('flip')) {
                            pullDownEl.className = '';
                            pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Pull down to refresh...';
                            this.minScrollY = -pullDownOffset;
                        } else if (this.y < (this.maxScrollY - 5) && !pullUpEl.className.match('flip')) {
                            pullUpEl.className = 'flip';
                            pullUpEl.querySelector('.pullUpLabel').innerHTML = '释放加载...';
                            this.maxScrollY = this.maxScrollY;
                        } else if (this.y > (this.maxScrollY + 5) && pullUpEl.className.match('flip')) {
                            pullUpEl.className = '';
                            pullUpEl.querySelector('.pullUpLabel').innerHTML = "继续上拉,查看详情";
                            this.maxScrollY = pullUpOffset;
                        }
                    },
                    onScrollEnd: function () {
                        if (pullDownEl.className.match('flip')) {
                            pullDownEl.className = 'loading';
                            pullDownEl.querySelector('.pullDownLabel').innerHTML = 'Loading...';        
                            pullDownAction(); // Execute custom function (ajax call?)
                        } else if (pullUpEl.className.match('flip')) {
                            pullUpEl.className = 'loading';
                            pullUpEl.querySelector('.pullUpLabel').innerHTML = 'Loading...';        
                            pullUpAction(); // Execute custom function (ajax call?)
                        }
                    }
                });
  
                setTimeout(function () { document.getElementById('wrapper').style.left = '0'; }, 800);
            }

            //上拉加载关闭开启

            //document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

           // document.addEventListener('DOMContentLoaded', function () { setTimeout(loaded, 200); }, false);
        </script>

        <style type="text/css" media="all">
            body,ul,li {
                padding:0;
                margin:0;
                border:0;
            }

            body {
                font-size:12px;
                -webkit-user-select:none;
                -webkit-text-size-adjust:none;
                font-family:helvetica;
            }

            #header {
                position:absolute; z-index:2;
                top:0; left:0;
                width:100%;
                height:45px;
                line-height:45px;
                padding:0;
                color:#eee;
                font-size:20px;
            }

           

            #footer {
                position:absolute; z-index:2;
                bottom:0; left:0;
                width:100%;
                height:48px;
                background-color:#222;
                background-image:-webkit-gradient(linear, 0 0, 0 100%, color-stop(0, #999), color-stop(0.02, #666), color-stop(1, #222));
                background-image:-moz-linear-gradient(top, #999, #666 2%, #222);
                background-image:-o-linear-gradient(top, #999, #666 2%, #222);
                padding:0;
                border-top:1px solid #444;
            }

            #wrapper {
                position:absolute; z-index:1;
                top:0px; bottom:48px; left:0px;
                width:100%;
                overflow:auto;
                -webkit-overflow-scrolling: touch;
                max-width: 640px;
            }

            #scroller {
                position:absolute; z-index:1;
                /*  -webkit-touch-callout:none;*/
                -webkit-tap-highlight-color:rgba(0,0,0,0);
                width:100%;
                padding:0;
            }

            #scroller ul {
                list-style:none;
                padding:0;
                text-align:left;
            }

            
            #myFrame {
                position:absolute;
                top:0; left:0;
            }
            .goods-intro{font-size:12px;line-height: 15px;color:#e94715;padding-left:10px;}
            .label-prom{font-size:12px;color:#fff;background: #dd2726;display: block;float: left;height: 20px;line-height: 20px;padding: 0px 4px;margin-top:4px;}
            .goods_price{width:100%;padding-left:10px;}
            .xiangq li{border:1px solid #ddd;border-top:0px;font-size:12px;color:#999;}
            .xiangq li:first-child{border-top:1px solid #ddd;}
            .xiangq li p{border-right:1px solid #ddd;padding:5px 8px;padding-right:15px;width:75px;}
            .xiangq li span{padding:0px 10px;}
            .btn{font-size: 12px;background: #ff9c00;padding: 6px 2px;display: block;width: 90px;text-align: center;line-height: 20px;color: #fff;border-radius: 5px;}
            .product_info .info_dottm{display: flex;cursor: pointer;}
            .sku_int{display: inline-block;line-height: 56px;vertical-align: middle;margin-left: 5px}

            /**
             *
             * Pull down styles
             *
            */
           /* #pullDown, #pullUp {
                background:#eee;
                height:60px;
                line-height:60px;
                padding:5px 10px;
                font-size:12px;
                color:#888;
                text-align: center;
            }
            .pullUpLabel{
                display: inline-block;
                height: 30px;
                line-height: 30px;
                vertical-align: middle;
            }
            #pullDown .pullDownIcon, #pullUp .pullUpIcon  {
                display:inline-block;
                width:30px; height:30px;
                background:url(__STATIC__/images/pull-icon@2x.png) 0 0 no-repeat;
                -webkit-background-size:30px; background-size:30px;
                -webkit-transition-property:-webkit-transform;
                -webkit-transition-duration:250ms;  
                vertical-align: middle;
            }
            #pullDown .pullDownIcon {
                -webkit-transform:rotate(0deg) translateZ(0);
            }
            #pullUp .pullUpIcon  {
                -webkit-transform:rotate(-180deg) translateZ(0);
            }

            #pullDown.flip .pullDownIcon {
                -webkit-transform:rotate(-180deg) translateZ(0);
            }

            #pullUp.flip .pullUpIcon {
                -webkit-transform:rotate(0deg) translateZ(0);
            }

            #pullDown.loading .pullDownIcon, #pullUp.loading .pullUpIcon {
                background-position:0 100%;
                -webkit-transform:rotate(0deg) translateZ(0);
                -webkit-transition-duration:0ms;

                -webkit-animation-name:loading;
                -webkit-animation-duration:2s;
                -webkit-animation-iteration-count:infinite;
                -webkit-animation-timing-function:linear;
            }

            @-webkit-keyframes loading {
                from { -webkit-transform:rotate(0deg) translateZ(0); }
            to { -webkit-transform:rotate(360deg) translateZ(0); }
            }*/

        </style>
    </head>
    <body >
        <div id="header">
          <div class="tab_nav">
            <div class="header">
              <div class="h-left"><a class="sb-back" href="javascript:history.back(-1);" title="返回"></a></div>
              <div class="h-mid">
                <ul>
                  <li><a href="javascript:;" class="tab_head on" id="goods_ka1" onClick="setGoodsTab('goods_ka',1,4)">商品</a></li>
                  <li><a href="javascript:;" class="tab_head" id="goods_ka2" onClick="setGoodsTab('goods_ka',2,4)">详情</a></li>
                  <li><a href="javascript:;" class="tab_head" id="goods_ka3" onClick="setGoodsTab('goods_ka',3,4)">属性</a></li>
                  <li><a href="javascript:;" class="tab_head" id="goods_ka4" onClick="setGoodsTab('goods_ka',4,4)">评价</a></li>
                </ul>
              </div>
              <div class="h-right">
                <aside class="top_bar">
                  <div onClick="show_menu();$('#close_btn').addClass('hid');" id="show_more"><a href="javascript:;"></a> </div>
                  <a href="{:U('Mobile/Cart/cart')}" class="show_cart"><em class="global-nav__nav-shop-cart-num" id="tp_cart_info"></em></a> 
                 </aside>
              </div>
            </div>
          </div>
        </div>
        <div id="wrapper">
            <div id="scroller">
               <!--  <div id="pullDown">
                    <span class="pullDownIcon"></span><span class="pullDownLabel"></span>
                </div> -->
                <ul id="thelist">
                    <div class="main" id="user_goods_ka_1" style="display:block;">
                    <div class="banner">
                      <div id="slider" class="slider" style="overflow: hidden; visibility: visible; list-style: none; position: relative;">
                        <ul id="sliderlist" class="sliderlist" style="position: relative; overflow: hidden; transition: left 600ms ease; -webkit-transition: left 600ms ease;">
                          <!--   <li><video id="video" controls="controls" autoplay="autoplay" src="http://dltest.dliansoft.com/public/b9f801dabb60dde768be0bd8e5623807.mp4" width="100%" height="400">Your browser does not support the video tag.</video></li> -->
                           <foreach  name="goods_images_list" item="pic">
                            <li style="float: left; display: block; width: 100%;"><span><a href="javascript:void(0)">
                            <img title="" width="100%" src="{$pic.image_url}"></a></span></li>
                           </foreach>
                        </ul>

                        <div id="pagenavi">
                         <foreach  name="goods_images_list" item="pic" key="k">
                          <a href="javascript:void(0);" <if condition="$k eq 0">class="active"</if>></a>
                         </foreach>
                      </div>
                      </div>
                    </div>
                    <div class="s_bottom"></div>
                    <script type="text/javascript">
                    $(function(){
                      $("div.module_special .wrap .major ul.list li:last-child").addClass("remove_bottom_line");
                    });
                    var active=0,
                      as=document.getElementById('pagenavi').getElementsByTagName('a');

                    for(var i=0;i<as.length;i++){
                      (function(){
                        var j=i;
                        as[i].onclick=function(){
                          t2.slide(j);
                          return false;
                        }
                      })();
                    }
                    var t2=new TouchSlider({id:'sliderlist', speed:600, timeout:6000, before:function(index){
                        as[active].className='';
                        active=index;
                        as[active].className='active';
                      }});
                    </script>
                        <form name="buy_goods_form" method="post" id="buy_goods_form" >
                          <div class="product_info">
                            <div class="info_dottm">
                              <h3 class="name">{$goods.goods_name}</h3>
                             <!--  <span class="btn">加入分销</span> -->

                            </div>
                             <div class="goods-intro">{$goods.goods_remark}</div>
                            <dl class="goods_price">
                              <script type="text/javascript" src="__STATIC__/js/lefttime.js"></script>
                              <dt> <i class="label-prom">{$prom_goods.name}</i><span <if condition="$goods['prom_type'] eq 0">id="goods_price"</if>>￥{$goods['price']}元</span><font>价格：￥{$goods.market_price}元</font> </dt>
                            </dl>
                            <ul class="price_dottm">
                              <li style=" text-align:left">折扣：{$goods.discount}折</li>
                              <li>{$commentStatistics.c0}人评价</li>
                              <li style=" text-align:right">{$goods.sale_num}人已付款</li>
                            </ul>
                          </div>
                         
                          <section id="search_ka" class="huodong">
                            <div class="subNav on">
                              <div class="att_title"> <span>折</span>
                                <p>优惠信息</p>
                              </div>
                            </div>
                            <div class="navContent" style="display: block;">
                                <if condition="$prom_goods neq null">
                                  <ul class="youhui_list1">
                                    <li>
                                      <a href="javascript:void(0);" title="{$prom_goods[name]}"><img src="__STATIC__/images/hui.png"></a>
                                      <a href="javascript:void(0);">{$prom_goods[description]|strip_tags=###}&nbsp;&nbsp;(活动时间：{$prom_goods[start_time]|date="m月d日",###} - {$prom_goods[end_time]|date="m月d日",###})</a>
                                    </li>
                                  </ul>
                                </if>
                                <tpshop sql="select * from `__PREFIX__prom_order` where start_time elt '$time' and end_time egt '$time' order by  id desc limit 5" item="v" key="k">
                                  <ul class="youhui_list1" style="margin-top:0px;">
                                      <if condition="strpos($v['group'],(string)$level) gt -1">
                                      <li><img src="__STATIC__/images/hui.png">{$v['name']}&nbsp;&nbsp;(活动时间：{$v[start_time]|date="m月d日",###} - {$v[end_time]|date="m月d日",###})</li>
                                    </if>
                                  </ul>
                                </tpshop>
                                <div class="blank10"></div>
                            </div>
                          </section>
                          <script>
                          var size=$('.navContent').find('li').size();
                          if(size<1){$('#search_ka').css('display','none')}
                          </script>
                        
                    <!--商品属性-->
                    <if condition="count($filter_spec) gt 0">
                    <section id="search_ka">
                    <!--属性-->
                    <div class="ui-sx bian1"> 
                    <div class="subNavBox"> 
                      <div class="subNav on"><strong>选择商品属性</strong></div>
                        <ul class="navContent" style="display:block;"> 
                        <foreach item="spec" key="key" name="filter_spec">
                        <li>   
                              <div class="title">{$key}</div>
                              <div class="item">
                              <foreach name="spec" item="v2" key="k2">
                                <a href="javascript:;" onclick="switch_spec(this);" title="{$v2[item]}" <if condition="$k2 eq 0">class="hover"</if>>
                                  <input type="radio" style="display:none;" name="goods_spec[{$key}]" value="{$v2[item_id]}" <if condition="$k2 eq 0 ">checked="checked"</if>/>
                                  {$v2[item]}        
                                  </a>
                               </foreach>
                              </div>                    
                        </li>
                        </foreach>
                           </ul>  
                        </div>
                        </div>    
                    </section> 
                    </if>
                          <section id="search_ka">
                            <div class="ui-sx bian1">
                              <div class="subNavBox">
                                <div class="subNav on"><strong>购买数量</strong></div>
                                <ul class="navContent" style="display: block;">
                                  <li style=" border-bottom:1px solid #eeeeee">
                                    <div class="item1"> 
                                      <span class="ui-number">
                                      <button type="button" class="decrease" onClick="goods_cut();">-</button>
                                        <input type="text" class="num" id="number" name="goods_num" value="1" min="1" max="1000"/>
                                        <input type="hidden" name="goods_id" value="{$goods.goods_id}"/>
                                        <button type="button" class="increase" onClick="goods_add();">+</button>
                                      </span> <span class="sku_int"></span><input type="hidden" value="" id="total_num" name="total_num"><input type="hidden" value="" id="sku_int" name="sku_int"></div>
                                  </li>
                                </ul>
                              </div>
                            </div>
                          </section>
                          <section id="search_ka">
                            <div class="ui-sx bian1">
                              <div class="subNavBox" >
                                <div class="subNav"><strong>会员专享价</strong></a></div>
                                <ul class="navContent" >
                                  <li  class="user_price">
                                  <tpshop sql="select * from __PREFIX__user_level" item="v" key="k">
                                    <div style="width:50%;float:left"><span class="key">{$v.level_name}：</span> <b class="p-price-v">{$v.discount|zhekshow=###}折</b> </div>
                                  </tpshop>
                                  </li>
                                </ul>
                              </div>
                            </div>
                          </section>
                    <script type="text/javascript">
                    $(function(){
                      $(".subNav").click(function(){    
                        $(this).next(".navContent").slideToggle(300).siblings(".navContent").slideUp(500);
                        $(this).toggleClass("on").siblings(".subNav").removeClass("on");
                        $('body').height($('body').height()+60);
                        myScroll.refresh()

                        if($(".is_scroll").length <= 0)
                        {
                          var scrollh=$('body')[0].scrollHeight+60;
                          //$('html,body').animate({'scrollTop':$('body')[0].scrollHeight},600);
                          myScroll.scrollTo(0,-scrollh,400);
                        }
                        
                      });
                      commentType = 1; // 评论类型
                      ajaxComment(1,1);// ajax 加载评价列表
                    })
                    </script> 
                    <script type="text/jscript">
                    function click_search (){
                      var search_ka = document.getElementById("search_ka");
                        if (search_ka.className == "s-buy open ui-section-box"){
                          search_ka.className = "s-buy ui-section-box";
                      }else {
                        search_ka.className = "s-buy open ui-section-box";
                      }
                    }
                     
                    function changeAtt(t) {
                      t.lastChild.checked='checked';
                      for (var i = 0; i<t.parentNode.childNodes.length;i++) {
                          if(t.parentNode.childNodes[i].className == 'hover') {
                              t.parentNode.childNodes[i].className = '';
                          t.childNodes[0].checked="checked";
                        }
                      }
                      t.className = "hover";
                      changePrice();
                    }

                    function changeAtt1(t) {
                      t.lastChild.checked='checked';
                      for (var i = 0; i<t.parentNode.childNodes.length;i++) {
                          if (t.className == 'hover') {
                                 t.className = '';
                          t.childNodes[0].checked = false;
                        }
                        else{
                          t.className="hover";
                          t.childNodes[0].checked = true;
                        }
                      }
                      changePrice();
                    }

                      function goods_cut(){
                          var num_val=document.getElementById('number');  
                          var new_num=num_val.value;  
                          var Num = parseInt(new_num);  
                          if(Num>1)Num=Num-1;  
                          num_val.value=Num;
                        }  
                        function goods_add(){
                          var num_val=document.getElementById('number'); 
                          var new_num=num_val.value;  
                          var Num = parseInt(new_num);  
                          Num=Num+1;  num_val.value=Num;
                        } 
                    </script>
                          <div style=" height:8px; background:#eeeeee; margin-top:-1px;"></div>
                          <!--
                          <div class="is_scroll">
                            <section id="search_ka">
                              <div class="ui-sx bian1">
                                <div class="subNavBox" >
                                  <div class="subNav" style=" border:0;"><a href="pocking.php?id=22" style=" border:0px;"><strong>自提点</strong></a></div>
                                </div>
                              </div>
                            </section>
                          </div>
                          -->
                          <!--
                          <div class="is_scroll">
                            <input type="hidden" id="chat_supp_id" value="1" />
                            <div style=" height:8px; background:#eeeeee; margin-top:-1px;"></div>
                            <section class="rzs_info">
                              <div class="top_info">
                                <dl>
                                  <dt><a href="supplier.php?suppId=1">
                                    <div style="background-image:url(./..//data/supplier/logo/logo_supplier1.jpg)"></div>
                                    </a></dt>
                                  <dd><strong>卖家: <a href="supplier.php?suppId=1" style="color:#333; font-size:18px;">天天果园旗舰店</a></strong><em>初级店铺</em></dd>
                                </dl>
                                <ul>
                                  <li><span>宝贝描述</span><strong>:5.0</strong><em>高</em></li>
                                  <li><span>卖家服务</span><strong>:5.0</strong><em>高</em></li>
                                  <li><span>物流服务</span><strong>:5.0</strong><em>高</em></li>
                                </ul>
                              </div>
                              <div class="s_dianpu"> <span><a href="tel:03350785268" style=" margin-left:7%;"><em class="bg1"></em>联系客服</a></span> <span><a href="supplier.php?suppId=1" style=" margin-left:3%;"><em class="bg2"></em>进入店铺</a></span> </div>
                            </section>
                          </div> 
                          -->
                        </form>
                      </div>

                        <div class="main" id="user_goods_ka_2" style="display:none">
                          <div class="product_main" style=" margin-top:50px;"> <!-- 产品图片 -->
                               <div class="product_images product_desc" id="product_desc">  </div>
                          </div>
                        </div>

                        <div class="main" id="user_goods_ka_3" style="display:none;">
                            <div class="product_main" style=" margin-top:50px;">
                              <section class="index_floor">
                                     <ul class="xiangq">
                                        <foreach name="goods_attr_list" item="v" key="k" >
                                        <li><p style="width:90px">{$goods_attribute[$v[attr_id]]}</p><span>{$v[attr_value]}</span></li>
                                        </foreach>
                                     </ul>
                                 </section>
                            </div>
                        </div>

                        <div class="tab_attrs tab_item hide main" id="user_goods_ka_4" style="display:none;"> 
                            <div id="ECS_COMMENT">
                            <link href="__STATIC__/css/photoswipe.css" rel="stylesheet" type="text/css">
                            <script src="__STATIC__/js/klass.min.js"></script> 
                            <script src="__STATIC__/js/photoswipe.js"></script>
                            <div class="my_comment_list" id="ECS_MYCOMMENTS"> </div>
                            
                            </div>
                        </div>
                </ul>
               <!--  <div id="pullUp">
                    <span class="pullUpIcon"></span><span class="pullUpLabel">继续上拉，查看详情</span>
                </div> -->
            </div>
        </div>
       <script>
           wx.config({
               debug: false,
               appId: '{$signPackage["appId"]}',
               timestamp: '{$signPackage["timestamp"]}',
               nonceStr: '{$signPackage["nonceStr"]}',
               signature: '{$signPackage["signature"]}',
               jsApiList: [
                   'chooseImage', 'uploadImage', 'downloadImage','hideMenuItems','onMenuShareAppMessage','onMenuShareTimeline'
               ]
           });

           wx.ready(function(){
               var ShareTitle = '{$goods.goods_name}';
               var ShareDesc = '{$goods.goods_name}';
       //      var ShareLink = "http://{$_SERVER[HTTP_HOST]}/index.php/Mobile/Goods/goodsInfo/id/"+'{$goods.goods_id}'+"/u_id/"+'{$user_id}'+".html"; //默认分享链接
               var ShareLink = 'www.baidu.com';
               var ShareImgUrl = '{$goods.original_img}'
               // 获取"分享到朋友圈"按钮点击状态及自定义分享内容接口
               wx.onMenuShareTimeline({
                   title: ShareTitle, // 分享标题
                   link:ShareLink,
                   imgUrl:ShareImgUrl // 分享图标
               });

               // 获取"分享给朋友"按钮点击状态及自定义分享内容接口
               wx.onMenuShareAppMessage({
                   title: ShareTitle, // 分享标题
                   desc: ShareDesc, // 分享描述
                   link:ShareLink,
                   imgUrl:ShareImgUrl // 分享图标
               });
               // 分享到QQ
               wx.onMenuShareQQ({
                   title: ShareTitle, // 分享标题
                   desc: ShareDesc, // 分享描述
                   link:ShareLink,
                   imgUrl:ShareImgUrl // 分享图标
               });
               // 分享到QQ空间
               wx.onMenuShareQZone({
                   title: ShareTitle, // 分享标题
                   desc: ShareDesc, // 分享描述
                   link:ShareLink,
                   imgUrl:ShareImgUrl // 分享图标
               });
           })
       </script>

       <script>
       function goTop(){
        $('html,body').animate({'scrollTop':0},600);
       }
       </script> 
       <a href="javascript:goTop();" class="gotop" style="z-index:99999"><img src="__STATIC__/images/topup.png"></a>
       <div style=" height:60px;"></div>
       <div class="footer_nav">
         <ul>
           <li class="bian"><a href="{:U('Index/index')}"><em class="goods_nav1"></em><span>首页</span></a> </li>
           <li class="bian"><a href="javascript:void(0)" onclick="open_kefu()"><em class="goods_nav2"></em><span>客服</span></a> </li>
           <li><a href="javascript:collect_goods({$goods.goods_id});" id="favorite_add"><em class="goods_nav3"></em><span>收藏</span></a></li>
         </ul>
         <dl>
           <dd class="flow"><a class="button active_button" href="javascript:void(0);" onClick="AjaxAddCart({$goods.goods_id},1,0);">加入购物车</a> </dd>
           <dd class="goumai"><a style="display:block;" href="javascript:void(0);"  onclick="AjaxAddCart({$goods.goods_id},1,1);">立即购买</a> </dd>
         </dl>
       </div>
       <script type="text/javascript" src="__PUBLIC__/static/js/layer/layer.js"></script>
       <script type="text/javascript">

       $(document).ready(function(){  
         
        $('#thelist').find('.main').css('min-height',function(){
          return getClientHeight()-60;
        })
         //向下翻页
         function nextpage(){
           var cur_id=parseInt($('.tab_head.on').attr('id').replace('goods_ka',''));
        
           if(cur_id<4){
                 $(window).off("scroll", scrollHandler);
                 var next_id=cur_id+1;
                 var cur_h=$('#user_goods_ka_'+next_id).height();
                 var scroll_h=cur_h-getClientHeight()+100;
                 $('.tab_head').removeClass('on');
                 $('#goods_ka'+next_id).addClass('on');
                 $('#user_goods_ka_'+next_id).css('display','block');
                 //$('#user_goods_ka_'+cur_id).animate({'height':0},500);
               // alert(cur_id+'|'+$('#user_goods_ka_'+cur_id).height())
                 var ss=$('#user_goods_ka_'+cur_id).height()+preheight;
                 preheight=$('#user_goods_ka_'+cur_id).height();

                 $('html,body').animate({'scrollTop':ss},500)
                 if(cur_id==3){
                   $('#user_goods_ka_'+cur_id).css('display','none');
                   $(window).scroll(scrollHandler)
                 }else{
                   setTimeout(function(){

                        $('#user_goods_ka_'+next_id).css({'position':'fixed','top':0});
                        
                        $('#user_goods_ka_'+cur_id).css('display','none');
                        $('#user_goods_ka_'+next_id).css({'position':'static'});

                        $('html,body').scrollTop('scrollTop',0);
                        $(window).scroll(scrollHandler)
                   },600)
                 }
                 
           }
           
                
         }
          //向上翻页
         function prepage(){

           cur_id=parseInt($('.tab_head.on').attr('id').replace('goods_ka',''));

         if(cur_id>1){

           $(window).off("scroll", scrollHandler);
           var pre_id=cur_id-1;
           $('.tab_head').removeClass('on');
           $('#goods_ka'+pre_id).addClass('on');
           $('#user_goods_ka_'+pre_id).css('display','block');
           var pre_h=$('#user_goods_ka_'+pre_id).height();
           $('#user_goods_ka_'+pre_id).height(0).animate({'height':pre_h},500);
           $('#user_goods_ka_'+cur_id).css('display','none');
           setTimeout(function(){
             $(window).scroll(scrollHandler)
           },300)
          }

         }


        // 更新商品价格
        get_goods_price();
         //加入分销
         $('.btn').click(function(){
           var goods_id=
           $.post('{:U("goods/add_mydist")}',{goods:'{$goods}'},function(){
               
           })
         })
       });

       function switch_spec(spec)
       {
         $(spec).siblings().removeClass('hover');
         $(spec).addClass('hover');
        $(spec).siblings().children('input').prop('checked',false);
        $(spec).children('input').prop('checked',true); 
          //显示库存
           show_sku_store();
           //更新商品价格
           get_goods_price();
           
       }
       //显示库存
       
       var outer_storege='{$outer_storege}';//外部库存是否开启
       var total_num=0;
       var sku_int=0;
       function show_sku_store(){
        if(outer_storege==1){
           var size_color='';
             $('.item').each(function(){
               size_color+=$(this).children('a.hover').children('input').val()+'_';
             })
             size_color=size_color.substr(0,size_color.length-1);
          $.post('{:U("Goods/sync_store")}',{goods_id:'{$goods.goods_id}',goods_sn:'{$goods.goods_sn}',size_color:size_color},function(res){
             var obj=jQuery.parseJSON(res);
                  sku_int=obj.current_num;
                 $('.sku_int').html('(库存:<i>'+obj.current_num+'</i>件)')
                 $('#sku_int').val(obj.current_num);
                 $('#total_num').val(obj.total_num);
          })
        }
       }
        show_sku_store();
       function open_kefu(){
         var url = "{:U('kefu/Webchat/index')}?user_id={$user.user_id}";
             layer.open({
                 type: 2,
                 title: '在线客服',
                 shadeClose: true,
                 shade: 0.8,
                 area: ['100%', '600px'],
                 content: url
             });
                $('body,html').height($(window).height()).css({
                 "overflow": "hidden"
             });

             var win_h= $(window).height();
             $('.layui-layer-iframe').height(win_h).css({'position':'fixed'});
             $('.layim-send-close,.layui-layer-close').click(function(){
               layer.closeAll();
               $("body").height('auto').css({
                       "overflow": "auto"
                 });
             })

           //connect(12);//连接用户
         
       }

       function get_goods_price()
       {
        var goods_price = {$goods.shop_price}; // 商品起始价
        var store_count = {$goods.store_count}; // 商品起始库存 
        if(outer_storege==1){
          store_count=total_num;
        }
        var spec_goods_price = {$spec_goods_price};  // 规格 对应 价格 库存表   //alert(spec_goods_price['28_100']['price']);  
        // 如果有属性选择项
        if(spec_goods_price != null && spec_goods_price !='')
        {
          goods_spec_arr = new Array();
          $("input[name^='goods_spec']:checked").each(function(){
             goods_spec_arr.push($(this).val());
          });    
          var spec_key = goods_spec_arr.sort(sortNumber).join('_');  //排序后组合成 key 
          goods_price = spec_goods_price[spec_key]['price']; // 找到对应规格的价格   
          store_count = spec_goods_price[spec_key]['store_count']; // 找到对应规格的库存
        }
        var goods_num = parseInt($("#goods_num").val()); 
        // 库存不足的情况
        if(goods_num > store_count)
        {
           goods_num = store_count;
           alert('库存仅剩 '+store_count+' 件');
           $("#goods_num").val(goods_num);
        }
           var flash_sale_price = parseFloat("{$goods['flash_sale']['price']}");
           (flash_sale_price > 0) && (goods_price = flash_sale_price);
        $("#goods_price").html('￥'+goods_price+'元'); // 变动价格显示

       }

       function sortNumber(a,b) 
       { 
        return a - b; 
       } 

       function ajaxComment(commentType,page){
           $.ajax({
               type : "GET",
               url:"/index.php?m=Mobile&c=goods&a=ajaxComment&goods_id={$goods['goods_id']}&commentType="+commentType+"&p="+page,//+tab,
               success: function(data){
                   $(".my_comment_list").empty().append(data);
                var myPhotoSwipe = $("#gallery a").photoSwipe({ 
                  enableMouseWheel: false, 
                  enableKeyboard: false, 
                  allowUserZoom: false, 
                  loop:false
                });
               }
           });
       }

       $(document).ready(function(){
          var cart_cn = getCookie('cn');
          if(cart_cn == ''){
          $.ajax({
            type : "GET",
            url:"/index.php?m=Home&c=Cart&a=header_cart_list",//+tab,
            success: function(data){
              cart_cn = getCookie('cn');            
            }
          }); 
          }
          $('#tp_cart_info').html(cart_cn);
       });


       //预览图片
         
              $('.sliderlist').find('img').click(function(){
             
                  var $this=$(this);
                  var h=$this.css('height');
                  var url = "{:U('Goods/viewpic')}";
                      layer.open({
                          type: 2,
                          title: '',
                          shadeClose: true,
                          shade: 0.8,
                          area: ['100%', h],
                          content: url
                      });

                  $('.layui-layer-close2').css({'margin-right':'15px','margin-top':'15px'})
              })
          
        //异步加载宝贝详情
        $('#goods_ka2').click(function(){
            var text=$('#product_desc').find('[name="text"]').val();
            if(text!=1){
               $('#product_desc').html('<div id="loading" style="text-align:center"><img src="__PUBLIC__/static/images/loading.gif" width="16"></div>');
               $.post('{:U("Goods/ajax_goods_desc")}',{goods_id:'{$goods.goods_id}'},function(res){
                   var htmlstr=res+'<input type="hidden" name="text" value="1">';
                   $('#product_desc').html(htmlstr);
               })
            }  
        })


       </script>
       <script src="__PUBLIC__/js/jqueryUrlGet.js"></script><!--获取get参数插件-->
       <script> set_first_leader(); //设置推荐人 </script>
        <!--微信浏览器 调用微信 分享js-->
       <if condition="$signPackage neq null">
        <include file="public/goods_share"/>
       </if>
      

    </body>
</html>